﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ImportDB
{
    public class PlainDataFileFactory
    {
        static PlainDataFileFactory FacInstance;

        public static PlainDataFileFactory Instance
        {
            get
            {
                if (FacInstance == null)
                {
                    FacInstance = new PlainDataFileFactory();
                }
                return  FacInstance;
            }
        }

        public IPlainDataFile GetPlainDatafile(string fileName)
        {
            if (fileName.EndsWith(".csv"))
            {
                return new CSVFile(fileName);
            }
            else if (fileName.EndsWith(".xls"))
            {
                return new XLSFile(fileName);
            }
            else if (fileName.EndsWith(".xlsx"))
            {
                return new XLSXFile(fileName);
            }
            else
            {
                return new UnKnownFile();
            }
        }
    }
}
